/**
 * 
 */
package com.module.bp.bus.graph;

/**
 * @author Donald
 */
public final class WeightedEdge {
	/** the first vertex the edge is incident on. */
	private int		from;
	/** the second vertex the edge is incident on. */
	private int		to;
	/** the edge's weight. */
	private float	weight;
	/**
	 * Creates a new instance of {@link WeightedEdge}.
	 * @param t the second vertex the edge is incident on
	 * @param f the first vertex the edge is incident on
	 * @param w the edge's weight
	 */
	public WeightedEdge(final int f, final int t, final float w) {
		from = f;
		to = t;
		weight = w;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(final Object obj) {
		boolean equals = false;
		if (obj instanceof WeightedEdge) {
			if (((WeightedEdge) obj).from == from
					&& ((WeightedEdge) obj).to == to
					&& ((WeightedEdge) obj).weight == weight) {
				equals = true;
			}
		}
		return equals;
	}
	/**
	 * Gets the the first vertex the edge is incident on.
	 * @return <code>int</code>
	 */
	public int getFrom() {
		return from;
	}
	/**
	 * Gets the the second vertex the edge is incident on.
	 * @return <code>int</code>
	 */
	public int getTo() {
		return to;
	}
	/**
	 * Gets the edge's weight.
	 * @return <code>float</code>
	 */
	public float getWeight() {
		return weight;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode() {
		return super.hashCode();
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("from ");
		sb.append(from);
		sb.append(" to ");
		sb.append(to);
		sb.append(" - ");
		sb.append(weight);
		return sb.toString();
	}
}
